package com.saas.dao;

import com.saas.pojo.Products;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductsDao {

    @Select("select * from products;")
    List<Products> getAllProducts();
    @Select("select * from products where cid = #{cid}")
    Products getProductById(Integer id);
    @Update("update products set title = #{title}, subtitle = #{subtitle}, cdesc = #{cdesc}, nprice = #{nprice}, oprice = #{oprice}, img = #{img}, tid = #{tid}, wtype = #{wtype} where cid = #{cid}")
    int updateProduct(Products product);
    @Delete("delete from products where cid = #{cid}")
    int deleteProduct(Integer id);

    @Insert("INSERT INTO products VALUES (#{cid}, #{title}, #{subtitle}, #{wtype}, #{img}, #{cdesc}, #{oprice}, #{nprice}, #{tid})")
    boolean saveProduct();
}
